package com.jy.project.mapper;

import com.jy.project.domain.Apply;
import com.jy.project.domain.ApplyCollect;
import com.jy.project.dto.ApplyDeptAdminQueryDTO;
import com.jy.project.dto.ApplyQueryDTO;
import com.jy.project.dto.ApplyUserQueryDTO;
import com.jy.project.vo.ApplyDeptAdminVO;
import com.jy.project.vo.ApplyQualitVO;
import com.jy.project.vo.ApplyUserVO;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.common.special.InsertListMapper;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

public interface ApplyMapper extends Mapper<Apply>,InsertListMapper<ApplyCollect> {

    List<ApplyQualitVO> listApplyyQualityVO(ApplyQueryDTO dto);

    List<ApplyDeptAdminVO> listDeptAdminApplyVO(ApplyDeptAdminQueryDTO dto);

    Apply  getApplyByApplyNo(@Param("applyNo") String applyNo);

    List<ApplyUserVO> listUserApplyVO(ApplyUserQueryDTO dto);

    default List<Apply> listApplyByExt(String  ext,Integer type){
        Example example=new Example(Apply.class);
        Example.Criteria criteria = example.createCriteria()
                .andEqualTo("applyType", type)
                .andEqualTo("ext", ext);
        List<Apply> applyList = selectByExample(example);
        return  applyList;
    }

    Apply  getApplyByMaterialNo(@Param("materialNo") String materialNo);

    default List<Apply>  listApply(String applyNo){

        Example example=new Example(Apply.class);
        Example.Criteria criteria = example.createCriteria()
                .andEqualTo("applyNo", applyNo)
                .andEqualTo("isDelete", 0);
        List<Apply> applyList = selectByExample(example);
        return  applyList;
    }
}